package c03正则表达式;

import org.junit.Test;

import java.util.Arrays;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * <p>
 *
 * @author: Yuanwl
 * @date: 2019/10/25 10:22
 */
public class 提取错误的批次ID {
    @Test
    public void test(){
        String cont = "开始自动撤销批次[6572847210545811456]...\n" +
                "2019.10.30 00:05:00.665 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6572847210545811456]成功\n" +
                "2019.10.30 00:05:00.665 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6547315035734020096]...\n" +
                "2019.10.30 00:05:01.187 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6547315035734020096]成功\n" +
                "2019.10.30 00:05:01.187 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6531810704192704512]...\n" +
                "2019.10.30 00:05:01.747 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6531810704192704512]成功\n" +
                "2019.10.30 00:05:01.747 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6582973452305567744]...\n" +
                "2019.10.30 00:05:02.271 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6582973452305567744]成功\n" +
                "2019.10.30 00:05:02.271 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6572846511850262528]...\n" +
                "2019.10.30 00:05:02.804 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6572846511850262528]成功\n" +
                "2019.10.30 00:05:02.804 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6531810464127520768]...\n" +
                "2019.10.30 00:05:03.279 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6531810464127520768]成功\n" +
                "2019.10.30 00:05:03.279 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6536233097778696192]...\n" +
                "2019.10.30 00:05:03.774 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6536233097778696192]成功\n" +
                "2019.10.30 00:05:03.775 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6532225559638839296]...\n" +
                "2019.10.30 00:05:04.236 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6532225559638839296]成功\n" +
                "2019.10.30 00:05:04.236 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6531810251799269376]...\n" +
                "2019.10.30 00:05:04.758 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6531810251799269376]成功\n" +
                "2019.10.30 00:05:04.758 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6573117456154365952]...\n" +
                "2019.10.30 00:05:05.278 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6573117456154365952]成功\n" +
                "2019.10.30 00:05:05.278 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6531810040783835136]...\n" +
                "2019.10.30 00:05:05.829 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6531810040783835136]成功\n" +
                "2019.10.30 00:05:05.829 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6539847667705450496]...\n" +
                "2019.10.30 00:05:06.077 [lls-Scheduler_Worker-36] INFO [com.lls.wec.local.batch.platform.task.AstRefundBackTask.lambda$execute$0:95] - 最终执行结果[true]，共0笔退款提交，0笔成功\n" +
                "2019.10.30 00:05:06.079 [lls-Scheduler_Worker-36] INFO [com.lls.wec.local.batch.base.service.BatStepSerialService.updateStepStatus:94] - 更新批量步骤[到期日退多余额款给付款白名单内企业-2019-\n" +
                "10-30T00:00:00.000+0800]状态:执行中-->成功, remark:处理成功\n" +
                "2019.10.30 00:05:06.085 [lls-Scheduler_Worker-36] INFO [com.lls.base.batch.quartz.job.BaseJob.execute:46] - 定时任务[astRefundBackTask.execute]用时：6.033s\n" +
                "2019.10.30 00:05:06.085 [lls-Scheduler_Worker-36] INFO [com.lls.base.batch.quartz.listener.JobListener.jobWasExecuted:87] - 定时任务执行结束：astRefundBackTask.execute\n" +
                "2019.10.30 00:05:06.318 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6539847667705450496]成功\n" +
                "2019.10.30 00:05:06.318 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6537922037082492928]...\n" +
                "2019.10.30 00:05:06.828 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6537922037082492928]成功\n" +
                "2019.10.30 00:05:06.828 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6572817709732466688]...\n" +
                "2019.10.30 00:05:07.316 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6572817709732466688]成功\n" +
                "2019.10.30 00:05:07.316 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6531809847506112512]...\n" +
                "2019.10.30 00:05:07.808 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6531809847506112512]成功\n" +
                "2019.10.30 00:05:07.808 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6531809372337606656]...\n" +
                "2019.10.30 00:05:08.292 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6531809372337606656]成功\n" +
                "2019.10.30 00:05:08.292 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6539847489653051392]...\n" +
                "2019.10.30 00:05:09.199 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6539847489653051392]成功\n" +
                "2019.10.30 00:05:09.199 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6582968479828152320]...\n" +
                "2019.10.30 00:05:09.729 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6582968479828152320]成功\n" +
                "2019.10.30 00:05:09.729 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6532222625731579904]...\n" +
                "2019.10.30 00:05:10.219 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6532222625731579904]成功\n" +
                "2019.10.30 00:05:10.220 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6588619286208581632]...\n" +
                "2019.10.30 00:05:10.368 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6588619286208581632]成功\n" +
                "2019.10.30 00:05:10.369 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:120] - 开始自动撤销批次[6559437323086336000]...\n" +
                "2019.10.30 00:05:10.863 [lls-Scheduler_Worker-34] INFO [com.lls.wec.local.batch.platform.task.LotTransferCashAutoCancelTask.lambda$null$2:123] - 自动撤销批次[6559437323086336000]成功";
        Pattern pattern = Pattern.compile("\\[(\\d{19})\\]");
        Matcher matcher = pattern.matcher(cont);

        StringBuilder sb = new StringBuilder();
        while (matcher.find()) {
            sb.append(matcher.group(1)).append(",");
        }

        String[] strings = sb.toString().split(",");
        Set<String> set = Arrays.asList(strings).stream().collect(Collectors.toSet());

        System.err.println(set);
    }
}
